var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    keyword:''
  },


  onLoad: function(options) {
    var store_id = wx.getStorageSync("store_id");
    this.setData({
      store_id:store_id
    })
  },

  setKeyword:function(e){
    console.log(e.detail.value)
    this.setData({
      keyword:e.detail.value
    })
  },

  sousuo:function(){
    var t = this;
    app.visit("huodong/sousuoDiyfood", {
      store_id:t.data.store_id,
      keyword:t.data.keyword
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          list:c.data
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  lijixuanz:function(e){
    var id = e.currentTarget.dataset.id;
    var t = this;
    app.visit("huodong/setDiyfood", {
      store_id:t.data.store_id,
      food_id:id
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        wx.showToast({
          title: '设置成功',
          icon: 'none',
          duration: 2000,
          success: function () {
            wx.navigateBack();
          }
        })
      }else{
        app.showToast(c.msg)
      }
    })
  }
  

})